package 不会写;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(12345);
        Socket accept = ss.accept();
        //接受客服端数据
        BufferedInputStream bis = new BufferedInputStream(accept.getInputStream());
        //把接受的数据 通过写入 到服务器的本地
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("Day16\\"));
        byte [] bytes = new byte[1024*8];
        int len;
        while ((len =bis.read(bytes))!=-1){
            bos.write(bytes,0,len);
            bos.flush();
        }
        //释放的是本地服务器
        bos.close();

        //传入数据给客户端回信息
        PrintWriter pw = new PrintWriter(accept.getOutputStream(),true);
        pw.println("上传成功！");
        pw.close();
        //释放资源
        ss.close();
    }
}
